﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Doo
{
    /// <summary>
    /// 为DataSource提供数据的Web服务的Request
    /// </summary>
    public interface WebServiceRequestVersionAble
    {
        /// <summary>
        /// 版本号
        /// </summary>
        string version { get; set; }
    }

    /// <summary>
    /// 可分页接口
    /// </summary>
    public interface WebServiceRequestPagerAble
    {
        /// <summary>
        /// 起始行[0-base]
        /// </summary>
        int rowstart { get; set; }
        /// <summary>
        /// 要取的行数
        /// </summary>
        int rowcount { get; set; }
    }

    /// <summary>
    /// 可用于接收DataSource请求的类
    /// </summary>
    public class WebServiceRequest : WebServiceRequestVersionAble, WebServiceRequestPagerAble
    {
        /// <summary>
        /// 版本号
        /// </summary>
        public string version { get; set; }
        /// <summary>
        /// 起始行[0-base]
        /// </summary>
        public int rowstart { get; set; }
        /// <summary>
        /// 要取的行数
        /// </summary>
        public int rowcount { get; set; }
    }

    public interface WebServiceResponseListable<T> where T : class
    {
        /// <summary>
        /// 记录数
        /// </summary>
        long RecordCount { get; set; }
        /// <summary>
        /// 数据项
        /// </summary>
        T[] Items { get; set; }
    }

    /// <summary>
    /// 为GridView提供数据的Web服务
    /// </summary>
    public class WebServiceResponse : WebServiceResponseListable<object>
    {
        /// <summary>
        /// 记录数
        /// </summary>
        public long RecordCount { get; set; }
        /// <summary>
        /// 数据项
        /// </summary>
        public object[] Items { get; set; }
    }

    /// <summary>
    /// 为GridView提供强类型化数据的Web服务
    /// </summary>
    /// <typeparam name="T">强类型化</typeparam>
    public class WebServiceResponse<T> : WebServiceResponseListable<T> where T : class
    {
        /// <summary>
        /// 记录数
        /// </summary>
        public long RecordCount { get; set; }
        /// <summary>
        /// 数据项
        /// </summary>
        public T[] Items { get; set; }
    }

}
